package com.test.design.pattern.memento.white_box;

/**
 * @ClasName Client
 * @Descripution TODO
 * @Author USER
 * @Date 2022/2/26 9:09
 * @Version V1.0
 */
public class Client {

    public static void main(String[] args) {
        System.out.println("---------------大战boos前-----------------");
        //创建游戏角色
        GameRole gameRole = new GameRole();
        gameRole.initState();
        gameRole.stateDisplay();

        //将该游戏角色内部状态进行备份
        //创建管理者对象
        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setRoleStateMemento(gameRole.saveState());

        System.out.println("---------------大战boos后-----------------");
        //损耗严重
        gameRole.fight();
        gameRole.stateDisplay();


        System.out.println("---------------恢复之前的状态-----------------");
        gameRole.recoverState(roleStateCaretaker.getRoleStateMemento());
        gameRole.stateDisplay();
    }

}
